package com.emergency.db.dao.staff;

import com.emergency.db.domain.staff.StaffStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface StaffStatusDao extends JpaRepository<StaffStatus, Long>, JpaSpecificationExecutor<StaffStatus> {
    @Modifying
    @Query(value = "delete FROM bas_staff_status WHERE staff_id = ? ", nativeQuery = true)
    void deleteAllByStaff(Long id);

    @Query("select ss from StaffStatus ss where staff.id=:id ")
    List<StaffStatus> findAllByStaff(@Param("id") Long id);
}
